package com.cn.lyl.servlet;

import com.alibaba.fastjson.JSONObject;
import com.cn.lyl.model.UserModel;
import com.cn.lyl.service.UserService;
import com.cn.lyl.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/user/userList")
public class UserListServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        UserService userService = new UserServiceImpl();
        UserModel userModel = new UserModel();
        List<UserModel> allUser = userService.findAllUser(userModel);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("allUser",allUser);
        resp.getWriter().print(jsonObject);
    }
}
